package com.gene.controller.MyProfile;

import com.gene.pojo.UpmsUser;
import com.gene.service.IUpmsUserService;
import com.gene.utils.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 我的资料   个人用户资料的补充接口
 */
@Controller
@RequestMapping("/gene-safe/myProfile")
public class MyProfileController {
    @Autowired
    private IUpmsUserService upmsUserService;

    /**
     * 根据userId 查询对应的数据
     */
    @RequestMapping("/query")
    @ResponseBody
    public ResultData query(UpmsUser upmsUser){
        ResultData resultData=new ResultData();
        UpmsUser u = upmsUserService.selectuserID(upmsUser.getUserId());
        if(u!=null){
            resultData.setData(u);
            resultData.setStatus("1");
            resultData.setMsg("查询成功");
        }else{
            resultData.setStatus("0");
            resultData.setMsg("查询失败");
        }
        return resultData;
    }

    /**
     * 只有修改  必须传userId
     * @param upmsUser
     * @return
     */
    @RequestMapping("/amend")
    @ResponseBody
    public ResultData amend(UpmsUser upmsUser){
        ResultData resultData=new ResultData();
        boolean a = upmsUserService.amend(upmsUser);
        if(a){
            resultData.setStatus("1");
            resultData.setMsg("修改成功");
        }else{
            resultData.setStatus("0");
            resultData.setMsg("修改失败");
        }
        return resultData;
    }
}
